<%@page import="com.teach.entity.Lj"%>
<%@page import="java.util.function.Supplier"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <jsp:include page="/admin/head.jsp"/>
  </head>
  <body>
	<jsp:include page="/admin/header.jsp"/>
	<jsp:include page="/admin/left-menu.jsp"><jsp:param value="1" name="index"/></jsp:include>
	<jsp:include page="/admin/footer.jsp"/>

    
<!--中间-->
    <section>
      <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
          <li class="breadcrumb-item">管理首页</li>
          <li class="breadcrumb-item">内容管理</li>
          <li class="breadcrumb-item active">新闻中心</li>
        </ol>
      </nav>
      
  
      
      <form class="form-inline">
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">新闻类别：</label>
          <select class="form-control">
            <option value="">全部</option>
          </select>
        </div>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">关键字：</label>
          <input type="text" class="form-control" placeholder="搜索关键字">
        </div>
        <button type="submit" class="btn btn-primary mb-2"><i class="fa fa-search"></i></button>
        <a href="admin/lj-add-form.jsp" class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">数量：</label>
          <select id="numSelect" class="form-control">
          	<option value="">显示条数</option>
            <option value="5" >每页5条</option>
            <option value="10">每页10条</option>
            <option value="20">每页20条</option>
            <option value="50">每页50条</option>
          </select>
        </div>
      </form>
<div class="ml-2 mr-2">
<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">帐号</th>
      <th scope="col">昵称</th>
      <th scope="col">性别</th>
      <th scope="col">电话号码</th>
      <th scope="col">QQ</th>
      <th scope="col">出生日期</th>
      <th scope="col">锁定</th>
      <th scope="col">操作</th>
    </tr>
  </thead>
  <tbody>
  <%
  List<Lj> list = (List<Lj>)request.getAttribute("list");
  for(int i=0;i<list.size();i++) {
	  Lj entity = list.get(i);
  %>
    <tr>
      <th scope="row"><%=i+1 %></th>
      <td><%=entity.getLjName() %></td>
      <td><%=entity.getLjNickname() %></td>
      <td><%=new Boolean(true).equals(entity.getLjSex())?"男":"女" %></td>
      <td><%=entity.getLjPhone() %></td>
      <td><%=entity.getLjQq() %></td>
      <td><%=format(entity.getLjBrithdate()) %></td>
      
      
      
      <td>
      <input class="switch" type="checkbox"<%if(new Integer(1).equals(entity.getLjStatus())){ %> checked="checked"<%} %>/>
      </td>
      <td class="p-1"><div class="dropdown">
  <button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
    操作
  </button>
  <div class="dropdown-menu dropdown-menu-right">
    <a class="dropdown-item" href="admin/lj-look.let?ljId=<%=entity.getLjId()%>">查看</a>
    <a class="dropdown-item" href="admin/lj-update-form.let?ljId=<%=entity.getLjId()%>">修改</a>
  	<a class="dropdown-item _delete" href="admin/lj-delete.let?ljId=<%=entity.getLjId()%>">删除</a>
  </div>
</div></td>
    </tr>
   <%} %>
  </tbody>
  
</table>

<% Long total = (Long)request.getAttribute("total");
int rowMax = 5;
int pageMax = (int)(total-1)/rowMax+1;
int current = 1;
try{
	current = Integer.valueOf(request.getParameter("current"));
}catch(Exception ex){
}
%>



<ul class="pagination justify-content-center">
	<li class="page-item"><a class="page-link" href="admin/lj-list-1.let?current=1&rowMax=5"> <span aria-hidden="true">&laquo;</span></a></li>
	<%for(int i = 1; i <= pageMax; i++){%>
	<li class="page-item <%=current==i?"active":""%>"><a class="page-link" href="admin/lj-list-1.let?current=<%=i %>&rowMax=5"><%=i %></a></li>
	<%} %>
	<li class="page-item"><a class="page-link" href="admin/lj-list-1.let?current=<%=pageMax %>&rowMax=5"> <span aria-hidden="true">&raquo;</span></a></li>
</ul>	


</div>
    </section>
   
  <div class="modal fade" id="confirmDialog" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">确认对话框</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        您确定要删除这条记录吗？
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <a href="#" class="btn btn-primary">确定</a>
      </div>
    </div>
  </div>
</div> 
    
<script type="text/javascript">

	//删除操作
	/**$("_delete").on("click",function(){
		//当点击删除的时候，删除成功的话，用户记录要少一条，并且拿到值，拿到值，就显示在页面呀
		request.getAttribute("msg");
		window.
		
	})**/
	
	/**$("._delete").on("click",function(){
		confirmDialog.find("a:last").attr("href",$(this).attr("href"));
		confirmDialog.modal("show");
		return false;
	});**/
	
	$("._delete").on("click",function(){
		let $this = $(this);
		sys.confirm("您需要删除这条记录吗？",function(ret){
			if(ret){
				location = $this.attr("href");
			}
		});
		return false;
	});



	var numSelect = document.getElementById("numSelect");
	numSelect.onchange = function(){
		window.location="admin/lj-list-1.let?current=1&rowMax="+this.value;
	}
</script>

  </body>
</html>
<%!
	//private  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private ThreadLocal<SimpleDateFormat> format = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
	public SimpleDateFormat get(){
		return new SimpleDateFormat("yyyy-MM-dd");
	}
});

private String format(Date date){
	if(date==null){
		return "-";
	} else {
		return format.get().format(date);
	}
}

private ThreadLocal<SimpleDateFormat> format1 = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
	public SimpleDateFormat get(){
		return new SimpleDateFormat("yyyy-MM-dd HH:mm");
	}
});

private String format1(Date date){
	if(date==null){
		return "-";
	} else {
		return format1.get().format(date);
	}
}

%>


  </body>
</html>
